package com.quotes.indicators;

import com.quotes.datamodell.*;

public class MacdIndicator
{
	private Quotes quotes = null;
	private TimeSeries closePrices = null;
	private TimeSeries emaShort = null;
	private TimeSeries emaLong = null;
	private TimeSeries macd = null;
	private TimeSeries signalLine = null;
	private TimeSeries macdHistogramm = null;
	
	public MacdIndicator(Quotes quotes, int macdShortTicks, int macdLongTicks, int singalLineTicks) {
		this.quotes = quotes;

		closePrices = quotes.getQuote(QuotesType.CLOSE);
		emaShort = TimeSeriesCalculator.calculateExponentialMovingAverage(closePrices, macdShortTicks);
    	emaLong = TimeSeriesCalculator.calculateExponentialMovingAverage(closePrices, macdLongTicks);
    	macd = emaShort.substract(emaLong);
    	signalLine = TimeSeriesCalculator.calculateExponentialMovingAverage(macd, singalLineTicks);
    	macdHistogramm = macd.substract(signalLine);
	}
	
	public TimeSeries getMacd() {
		return macd;
	}
	
	public TimeSeries getSingalLine() {
		return signalLine;
	}
	
	public TimeSeries getEmaShort() {
		return emaShort;
	}
	
	public TimeSeries getEmaLong() {
		return emaShort;
	}

	public TimeSeries getMacdHistogramm() {
		return macdHistogramm;
	}
}
